﻿using Api.Ordering.Tool;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Api.Ordering.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class MenuController : ControllerBase
    {

        [HttpGet("getmenulist")]
        public Result GetMenuList()
        {
             
            return new Result(GetList());
        }

        public List<Menu> GetList()
        {
            var menu = new List<Menu>();

            var list = new List<Menu>();
            list.Add(new Menu() { Id = 1, PId = 100, Title = "角色", Name = "role", Path = "/system/role", Url = "system/roles/index.vue" });
            list.Add(new Menu() { Id = 3, PId = 100, Title = "菜单管理", Name = "menu", Path = "/system/menu", Url = "system/menu/index.vue" });
            list.Add(new Menu() { Id = 4, PId = 100, Title = "权限管理", Name = "perss", Path = "/system/perss", Url = "system/user/index.vue" });
            list.Add(new Menu() { Id = 4, PId = 100, Title = "附件上传", Name = "fileupload", Path = "/system/fileupload", Url = "test/test-FileUpload.vue" });
            menu.Add(new Menu() { Id = 100, PId=0, Title = "系统管理", Name = "system", Path = "/system",Children=list});


            //var list2 = new List<Menu>();
            //list2.Add(new Menu() { Id = 1, PId = 110, Title = "列表1", Name = "list1", Path = "/home/list1", Url = "home/list1.vue" });
            //list2.Add(new Menu() { Id = 3, PId = 110,  Title = "列表2", Name = "list2", Path = "/home/list2", Url = "home/list2.vue" });
            ////list2.Add(new Menu() { Id = 4, Title = "百度", Name = "baidu", Path = "http://www.baidu.com", Url = "http://www.baidu.com" });
            //menu.Add(new Menu() { Id = 110, PId = 0, Title = "首页", Name = "home", Path = "/home", Url = "home/index.vue" ,Children=list2});

            return menu;
        }

    }


    public class Menu
    {
        public int PId { get; set; }
        public int Id { get; set; }
        public string Title { get; set; }
        public string Name { get; set; }
        public string Path { get; set; }
        public string Redirect { get; set; }
        public string Url { get; set; }
        public List<Menu> Children { get => children; set => children = value; } 

        private List<Menu> children = new List<Menu>();


    }
}
